<?php

namespace yak\layui\helper;

use yak\layui\models\AdminConfig;
use yii\helpers\ArrayHelper;
use yii\helpers\Json;

/**
 * Class ConfigHelper
 * @package yak\layui\controllers
 */
class ConfigHelper
{
    public static function theme()
    {
        $config = \Yii::$app->user->isGuest ? [] : AdminConfig::config();
        $theme = ArrayHelper::getValue($config, 'theme', '');
        $flexible = ArrayHelper::getValue($config, 'flexible', 0);
        return [
            'theme' => $theme, 'shrink' => $flexible == 1 ? 'layadmin-side-shrink' : ''
        ];
    }

    public static function env($config)
    {
        return 'var YAK_CONFIG=' . Json::encode($config);
    }
}